﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using BTN04.DTO;
using System.Collections.Generic;

namespace BTN04.DAO
{
    public class NhaSanXuatDAO
    {
        public List<NhaSanXuatDTO> DanhSach()
        {
            string sql = "SELECT * FROM NhaSanXuat WHERE MaTinhTrangNhaSanXuat = 1 ";
            SqlConnection cnn = new SqlConnection(DataProvider.ConnectionString);
            cnn.Open();
            SqlCommand comand = new SqlCommand(sql,cnn);
            SqlDataReader read = comand.ExecuteReader();
            List<NhaSanXuatDTO> lst = new List<NhaSanXuatDTO>();
            while (read.Read())
            {
                NhaSanXuatDTO nsxDTO = new NhaSanXuatDTO();
                nsxDTO.MaNhaSanXuat = Convert.ToInt32(read["MaNhaSanXuat"]);
                nsxDTO.TenNhaSanXuat = read["TenNhaSanXuat"].ToString();
                nsxDTO.MaTinhTrangNhaSanXuat = Convert.ToInt32(read["MaTinhTrangNhaSanXuat"]);
                lst.Add(nsxDTO);
            }
            return lst;
        }
    }
}
